package com.ruoyi.contract.domain;

import com.baomidou.mybatisplus.annotation.*;

import java.io.*;
import java.math.BigDecimal;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ice.core.annotation.IceField;
import lombok.Data;

/**
 * 
 * @TableName ice_conf
 */
@TableName(value ="ice_conf")
@Data
public class IceConf implements Serializable {
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * remote application id
     */
    private Integer app;

    /**
     * 
     */
    private String name;

    /**
     * 
     */
    private String sonIds;

    /**
     * see NodeTypeEnum
     */
    private Integer type;

    /**
     * 1 online 0 offline
     */
    private Integer status;

    /**
     * make true->false false->true
     */
    private Integer inverse;

    /**
     * leaf node class name
     */
    private String confName;

    /**
     * leaf node json config
     */
    private String confField;

    /**
     * 
     */
    private Long forwardId;

    /**
     * see TimeTypeEnum
     */
    private Integer timeType;

    /**
     * 
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date start;

    /**
     * 
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date end;

    /**
     * 
     */
    private Integer debug;

    /**
     * NULL/3-SHUTDOWN, 0-CONTINUE_FALSE, 1-CONTINUE_TRUE, 2-CONTINUE_NONE
     */
    private Integer errorState;

    /**
     * 
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createAt;

    /**
     * 
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateAt;

    @TableField(exist = false)
    private Long flowId;

    @TableField(exist = false)
    private String flowValue;

    @TableField(exist = false)
    private Long selectId;

    //下拉框 节点类型 4 Relation 5 Flow 6 Result
    @TableField(exist = false)
    private Integer nodeType;

    @TableField(exist = false)
    private Long ruleId;

    @TableField(exist = false)
    private BigDecimal unitPrice;

    @TableField(exist = false)
    private String resultType;

    @TableField(exist = false)
    private Long workNumId;

    @TableField(exist = false)
    private Long workDaysId;

    @TableField(exist = false)
    private Long ladderDaysId;

    @TableField(exist = false)
    private BigDecimal minValue;

    @TableField(exist = false)
    private BigDecimal maxValue;

    @TableField(exist = false)
    private Long parentId;

    @TableField(exist = false)
    private String nextId;

    @TableField(exist = false)
    private Long index;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;


    /**
     * 深拷贝
     * @return 新的IceConf对象
     */
    public IceConf deepCopyIceConf() {
        IceConf iceConf = null;
        try {
            // 将该对象序列化成流，因为写在流里的是对象的一个拷贝，而原对象仍然存在于JVM里面。所以利用这个特性可以实现对象的深拷贝
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(this);
            // 将流序列化成对象
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            ObjectInputStream ois = new ObjectInputStream(bais);
            iceConf = (IceConf) ois.readObject();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return iceConf;
    }
}